#include "stdafx.h"

#include "Log.h"

#include "DateTime.h"

#include <iostream>

namespace StdTools
{
	Log::Log(std::string name, bool cmd)
	{
		this->file.open(name.data());
		this->cmd = cmd;
		this->logMessage("Creado fichero de log: "+name);
	}
	
	Log::~Log()
	{
		this->file.close();
	}

	void Log::logMessage(std::string message)
	{
		DateTime * time = DateTime::CurrentTime();
		this->file<<*time<<": "<<message<<std::endl;
		if (this->cmd)
			std::cout<<*time<<": "<<message<<std::endl;
	}
}
